package com.kotlin.hxh.ui.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.kotlin.hxh.R
import com.kotlin.hxh.base.BaseBackFragment
import kotlinx.android.synthetic.main.fragment_cycle.*
import kotlinx.android.synthetic.main.toolbar.*

/**
 * @author huxh
 * @date 2018/12/20.
 */
class CycleFragment : BaseBackFragment() {
    companion object {
        private val ARG_NUMBER = "arg_number"
        @JvmStatic
        fun newInstance(number: Int): CycleFragment {
            val fragment = CycleFragment()
            val args = Bundle()
            args.putInt(ARG_NUMBER, number)
            fragment.arguments = args
            return fragment
        }
    }

    private var mNumber: Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        mNumber = arguments?.getInt(ARG_NUMBER, 0)!!
    }

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) = inflater.inflate(R.layout.fragment_cycle, container, false)

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        initView()
    }

    private fun initView() {
        toolbar.title = "CyclerFragment $mNumber"
        initToolbarNav(toolbar)
        tv_name.text = "CyclerFragment $mNumber"
        btn_next.setOnClickListener { start(CycleFragment.newInstance(mNumber + 1)) }
        btn_next_with_finish.setOnClickListener { startWithPop(CycleFragment.newInstance(mNumber + 1)) }
    }

}